package altfee.example.EraseImage;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.Toast;

public class EraseImageActivity extends Activity {
	
	private ImageEraser mFloatImage = null;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {        
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        mFloatImage = new ImageEraser(this);
        mFloatImage.prepare();
        RelativeLayout ly = (RelativeLayout) findViewById(R.id.frontImg);
        ly.addView(mFloatImage);
        
        Button ctrlBtn = (Button) findViewById(R.id.btn_earse);
        ctrlBtn.setOnClickListener(aListener);
        ctrlBtn = (Button) findViewById(R.id.btn_unearse);
        ctrlBtn.setOnClickListener(aListener);
        ctrlBtn = (Button) findViewById(R.id.btn_save);
        ctrlBtn.setOnClickListener(aListener);
    }
    
    private OnClickListener aListener = new OnClickListener(){

		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			switch(v.getId())
			{
			case R.id.btn_earse:
				mFloatImage.switchEraseMode(true);
				break;
			case R.id.btn_unearse:
				mFloatImage.switchEraseMode(false);
				break;
			case R.id.btn_save:
				if(mFloatImage.apply())
					Toast.makeText(EraseImageActivity.this, "Saved as /sdcard/out.png", Toast.LENGTH_LONG).show();
				break;
			default:
					break;
			}
		}};
}